

<div class="layui-form" lay-filter="layuiadmin-form-departmentadmin" style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">上级部门</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="hidden" name="pidh" id="pidh" value="{{ d.params.departmentPid || '' }}" placeholder="请选择上级部门" autocomplete="off" class="layui-input">
                <select name="pdnames" id="pdnames"></select>
                <option value="">请选择上级部门</option>
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="cname" value="{{ d.params.departmentName || '' }}" lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input">
                <input type="hidden" name="cid" value="{{ d.params.departmentId || '' }}" lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item" lay-filter="status">
        <label class="layui-form-label">选择状态</label>
        <div class="layui-input-block">
            <script type="text/html" template>
                <input type="radio" name="cflag" value="0" title="启用" checked="checked" {{ d.params.departmentFlag === '0' ? 'checked' : '' }}>
                <input type="radio" name="cflag" value="1" title="禁用" {{ d.params.departmentFlag === '1' ? 'checked' : '' }}>
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-department-front-submit" value="确认" class="layui-btn">
        </div>
    </div>
</div>
<script>
    layui.use(['admin','form'],function (){
        var $=layui.$
            ,form=layui.form
            ,layer=layui.layer;
        $.ajax({
            url:'/getDeptsServlet'
            ,dataType:'json'
            ,type:'post'
            ,success:function (data){
                $.each(data.data,function (index,value){
                    $('#pdnames').append(new Option(value.departmentName,value.departmentId));
                });
                $('#pdnames').val($('#pidh').val())
                form.render('select');
            }
        });
    });
</script>
